#include <iostream>

using namespace std;

const int N = 110;
int n, m;
int x[N], w[N], v[N];
int f[N];
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> x[i] >> w[i] >> v[i];

	for (int i = 1; i <= n; i++)
		for (int j = m; j >= w[i]; j--)
			for (int k = 1; k <= x[i]; k++)
			{
				if(j >= w[i] * k)
					f[j] = max(f[j], f[j - w[i] * k] + k * v[i]);
			}
	
	cout << f[m] << endl;
	return 0;
}